<?php

namespace App\Http\Controllers;

use App\Demos;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use EasyWeChat\Factory;

class Update extends Controller
{
    public function index(){
        return view('update.addImg');
    }

    public function add(Request $request){
        if ($request->isMethod('post')){
            $file=$request->file('file_data');//获取文件值
            if($file){
                $extension=$file->guessExtension();
                $newName=md5(time().rand(1,8888)).".".$extension;
                $file->move(Config::get('app.upload_dir'),$newName);
                $imgPuth=Config::Get('app.upload_dir').$newName;
                $arr['code']=1;
                $arr['msg']='上传成功';
                $arr['data']=$imgPuth;
                return json_encode($arr);
            }
        }



    }

}